<template>
	<view :style="themeColor">
		<view class="page">
			<!---logoflex布局开始-->
			<view class="flex flex-direction flex-wrap align-center justify-center benben-flex-layout logon_flex_0">
				<image class='logon_fd0_0' mode="aspectFill" :src='STATIC_URL+"logo1.png"'></image>
				<!-- <text class='logon_fd0_1'>欢迎来到商家端</text> -->
			</view>

			<!---logoflex布局结束-->
			<!---登录flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout logon_flex_1">
				<view class='flex flex-wrap align-center logon_fd1_0'>
					<image class='logon_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"7.png"'></image>
					<benben-input class='flex-sub logon_fd1_0_c1' type="number" :placeholder="`请输入手机号`"
						confirm-type="done" :maxlength="11"
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="mobile" />
				</view>
				<view class='flex flex-wrap align-center logon_fd1_0'>
					<image class='logon_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"8.png"'></image>
					<benben-flex-password-diy v-model="password"
						class-name="flex align-center flex-sub flex logon_fd1_1_c1" :placeholder="'请输入密码(6~12位字母+数字)'"
						:maxlength="12" :default-type='true'
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx">
						<template #show>
							<text class='fu-iconfont2  logon_fd1_1_c1_icon1' data-type="show">&#xE837;</text>
						</template>
						<template #hide>
							<text class='fu-iconfont2  logon_fd1_1_c1_icon1' data-type="hide">&#xEBCC;</text>
						</template>
					</benben-flex-password-diy>
				</view>
				<text class='self-end logon_fd1_2' @tap.stop="handleJumpDiy" data-type="navigateTo"
					:data-url="`/pages/login/codeLogins/codeLogins`">验证码登录</text>
				<button class='logon_fd1_3' @tap.stop="loginFunc()">登录</button>
				<view class='flex flex-wrap align-center justify-center logon_fd1_4'>
					<text class='logon_fd1_4_c0' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/login/registers/registers`">注册账号</text>
					<view class='flex flex-wrap align-center logon_fd1_4_c1'>
					</view>
					<text class='logon_fd1_4_c0' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/login/forgotPassword/forgotPassword`">忘记密码</text>
				</view>
			</view>

			<!---登录flex布局结束-->
			<view class="flex flex-direction align-center benben-position-layout flex logon_flex_2">
				<view class='flex flex-wrap align-center'>
					<benben-flex-switch-new class-name='flex flex logon_fd2_0_c0' v-model="is_tick" :disabled='false'>
						<template v-slot:checked>

							<view class='flex flex position-relative align-center'>
								<image class='logon_checkfd2_0_c0_c0_c0' mode="aspectFit" :src='STATIC_URL+"9.png"'>
								</image>
							</view>

						</template>
						<template v-slot:unchecked>

							<view class='flex flex position-relative justify-end align-center'>
								<image class='logon_noCheckfd2_0_c0_c1_c0' mode="aspectFit" :src='STATIC_URL+"10.png"'>
								</image>
							</view>

						</template>
					</benben-flex-switch-new>
					<text class='logon_fd2_0_c1'>已阅读并同意</text>
					<text class='logon_fd2_0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/login/agreements/agreements`">《用户协议》</text>
					<text class='logon_fd2_0_c1'>与</text>
					<text class='logon_fd2_0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/login/tactics/tactics`">《隐私政策》</text>
				</view>

			</view>
			<view :style="{height: '80rpx'}"></view>
			<benben-popup v-model="popupShow1710747849463" :mask="true" :mask-close-able="false" mode='center'
				:z-index='999'>
				<!---退出登录flex布局开始-->
				<view class="flex flex-direction flex-wrap align-center login_flex_1"
					@tap.stop="popupShow1650940432200=true">
					<text class='login_fd1_0'>该账号已申请注销</text>
					<text class='login_fd1_1'>是否撤销注销？</text>
					<view class='flex flex-wrap align-center login_fd1_2'>
						<button class='login_fd1_2_c0' @tap.stop="popupShow1710747849463=false">否</button>
						<button class='login_fd1_2_c1' @tap.stop="setRevocationFunc()">是</button>
					</view>
				</view>
				<!---退出登录flex布局结束-->
			</benben-popup>

		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"popupShow1710747849463": false,
				"is_tick": false,
				// "mobile": "17300000003",
				// "password": "123456a",
				"mobile": "",
				"password": "",
				"loginData": {
					"userinfo": {
						"user_token": "",
						"id": "",
						"avatar": "",
						"real_name": "",
						"nickname": "",
						"email": "",
						"gender": "",
						"mobile": "",
						"birthday": "",
						"phone": "",
						"user_type": "",
						"certified_status": "",
						"userlevel_id": "",
						"shopID": ""
					}
				}
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
			isLogin() {
				return this.$store.state.token == '' ? false : true;
			},
			/**
			 * @returns 
			 * Android       安卓
			 * IOS       苹果
			 * Web       H5 或 pc
			 * Wechat       微信小程序
			 * Alipay       支付宝小程序
			 * Baidu       百度小程序
			 * ByteBounce       抖音小程序
			 * 360       360小程序
			 * FastApp       快应用
			 */
			appSystemIdentification() {
				return this.$store.state.appSystemIdentification
			}
		},
		watch: {},
		onLoad(options) {

		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//登录
			async loginFunc() {
				if (!validate(this.mobile, 'require')) {
					this.$message.info('手机号不能为空');
					return false;
				}
				if (!validate(this.mobile, 'phone')) {
					this.$message.info('请输入正确的手机号');
					return false;
				}
				if (!validate(this.password, 'require')) {
					this.$message.info('请输入密码(6~12位字母+数字)');
					return false;
				}
				if (!validate(this.password, 'password')) {
					this.$message.info('请输入正确密码(6~12位字母+数字)');
					return false;
				}
				if (this.is_tick === false) {
					this.$message.info('请先阅读并同意《用户注册协议》与《隐私政策》');
					return false;
				}
				//请求方法
				//数据验证

				let dataloginData = await this.$api.dbPost(global.apiUrls.post5c78dbfd977cf, {
					mobile: this.mobile,
					password: this.password,
					user_type: '3'
				});
				if (!dataloginData) return
				if (dataloginData.data.code == -999) {
					this.popupShow1710747849463 = true
					return
				}
				if (dataloginData.data.code == 400) {
					this.$message.info('您还未设置登录密码')
					setTimeout(() => {
						this.$urouter.navigateTo(
							`/pages/login/forgotPassword/forgotPassword?type=newset&account=${this.mobile}`
						);
					}, 500)
					return
				}
				if (dataloginData.data.code != 1) {
					this.$message.info(dataloginData.data.msg);
					return
				}
				let infologinData = dataloginData.data;
				this.loginData = infologinData.data
				this.$store.commit('updateUserInfo', this.loginData.userinfo)
				this.$store.commit('saveToken', this.loginData.userinfo.user_token)
				uni.setStorageSync('shopID', this.loginData.userinfo.shopID);
				this.getClient()
				this.$urouter.switchTab(`/pages/tabBar/index/index`);

			},
			//消息推送
			getClient() {
				/* 获取设备ID用作消息推送 start */
				// #ifdef APP-PLUS
				let client_id = plus.push.getClientInfo().clientid;
				console.log('设备client_id：' + client_id);
				if (client_id) {
					this.$api.post(global.apiUrls.post6655424618774, {
							client_id: client_id,
							client_type: this.appSystemIdentification == 'Android' ? 1 : 2
						})
						.then(result => {
							console.log('设备储存', result);
						});
				}
				// #endif
				/* 获取设备ID end */
			},
			//获取撤销
			async setRevocationFunc() {
				//请求方法
				//数据验证

				let data65af32616116b = await this.$api.dbGet(global.apiUrls.post65af32616116b, {
					mobile: this.mobile
				});
				if (!data65af32616116b) return
				if (data65af32616116b.data.code != 1) {
					this.$message.info(data65af32616116b.data.msg);
					return
				}
				setTimeout(() => {
					this.loginFunc()
				}, 1000)

			},
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #fff;
		background-size: 100% auto;
	}

	.logon_flex_0 {
		padding: 110rpx 0rpx 100rpx 0rpx;
	}

	.logon_fd0_1 {
		line-height: 56rpx;
		font-size: 40rpx;
		font-weight: 500;
		color: #333333;
		margin: 32rpx 0rpx 0rpx 0rpx;
	}

	.logon_fd0_0 {
		width: 505rpx;
		height: 150rpx;
	}

	.logon_flex_1 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.logon_fd1_4_c1 {
		background: rgba(153, 153, 153, 1);
		width: 1rpx;
		height: 20rpx;
		margin: 0rpx 20rpx 0rpx 20rpx;
		background-size: 100% auto;
	}

	.logon_fd1_4_c0 {
		font-size: 28rpx;
		font-weight: 400;
		color: #999999;
		line-height: 40rpx;
	}

	.logon_fd1_4 {
		line-height: 40rpx;
		margin: 40rpx 0rpx 0rpx 0rpx;
	}

	.logon_fd1_3 {
		background: #E31D1A;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #fff;
		height: 80rpx;
		line-height: 80rpx;
		font-weight: 500;
		width: 638rpx;
		margin: 0rpx 24rpx 0rpx 24rpx;
	}

	.logon_fd1_2 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
		margin: 32rpx 0rpx 48rpx 0rpx;
	}

	.logon_fd1_1_c1_icon1 {
		text-align: center;
		font-size: 34rpx;
	}

	::v-deep .logon_fd1_1_c1 {
		font-size: 32rpx;
		color: #333;
		font-weight: 400;
		width: 620rpx;
	}

	.logon_fd1_1_c0 {
		width: 34rpx;
		height: 34rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 28rpx 0rpx 0rpx;
	}

	.logon_fd1_0_c1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333;
	}

	.logon_fd1_0_c0 {
		width: 34rpx;
		height: 34rpx;
		margin: 0rpx 28rpx 0rpx 0rpx;
	}

	.logon_fd1_0 {
		border-bottom: 1px solid #eee;
		padding: 40rpx 0rpx 40rpx 0rpx;
	}

	.logon_flex_2 {
		background: #fff;
		width: 750rpx;
		height: 80rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
		background-size: 100% auto !important;
	}

	.logon_fd2_0_c2 {
		line-height: 33rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #E31D1A;
	}

	.logon_fd2_0_c1 {
		line-height: 33rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: var(--benbenFontColor0);
	}

	.logon_noCheckfd2_0_c0_c1_c0 {
		width: 36rpx;
		height: 36rpx;
	}

	.logon_checkfd2_0_c0_c0_c0 {
		width: 32rpx;
		height: 32rpx;
	}

	::v-deep .logon_fd2_0_c0 {
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	//弹窗
	.login_flex_1 {
		background: #fff;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.login_fd1_0 {
		font-size: 36rpx;
		font-weight: 800;
		line-height: 44rpx;
		color: #333333;
		margin: 40rpx 0rpx 40rpx 0rpx;
	}

	.login_fd1_1 {
		line-height: 44rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
	}

	.login_fd1_2_c1 {
		border-top: 1px solid rgba(238, 238, 238, 1);
		border-left: 1px solid rgba(238, 238, 238, 1);
		background: #fff;
		line-height: 110rpx;
		border-radius: 0rpx 0rpx 16rpx 0rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor4);
		width: 264rpx;
	}

	.login_fd1_2_c0 {
		border-top: 1px solid #eee;
		background: #fff;
		line-height: 110rpx;
		border-radius: 0rpx 0rpx 0rpx 16rpx;
		font-size: 32rpx;
		color: rgba(153, 153, 153, 1);
		padding: 0rpx 103rpx 0rpx 103rpx;
	}

	.login_fd1_2 {
		margin: 37rpx 0rpx 0rpx 0rpx;
	}
</style>